import 'package:flutter/material.dart';
import 'package:shihui/resources/colors.dart';
import 'package:shihui/resources/res_index.dart';
import 'package:shihui/utils/util_index.dart';

class LocationPage extends StatefulWidget  {
  @override
  _LocationPageState createState() {
    // TODO: implement createState
    return _LocationPageState();
  }
}

class _LocationPageState extends State<LocationPage> with SingleTickerProviderStateMixin {

  TabController _tabController;
  int _selectedIndex = 0;

  var titles = [Ids.titleStore, Ids.titleMap];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController =
    new TabController(vsync: this, initialIndex: _selectedIndex, length: titles.length);
    _tabController.addListener(() {
      setState(() => _selectedIndex = _tabController.index);
      print("location-> ${_tabController.indexIsChanging}");
    });
  }


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    var tabs = titles.map((title) {
      return Tab(text: IntlUtil.getString(context, title));
    }).toList();

    return Column(
      children: <Widget>[
        Container(
          color: Colors.white,

          child: TabBar(
            tabs: tabs,
            controller: _tabController,
            indicatorColor: Theme.of(context).primaryColor,
            labelColor: Theme.of(context).primaryColor,
            unselectedLabelColor: ColorT.text_dark,
            labelStyle: TextStyle(
                fontSize: ScreenUtil.getScaleSp(context, 14.0),
                color: Theme.of(context).primaryColor),
          ),
        )
      ],
    );
  }
}